<?php

	/**
	 * castField - sql_dropdown
	 * 
	 * Create an Dropdown Menu Element based on a Database Request. For selecet a job from a dropdown based on a jobs table.
	 * 
	 * @author bsuter
	 */
	class Devmod_method_castField_sql_dropdown extends Devmod_castField_abstraction {
		
		public function type_edit()
		{
			$this->args['where'] = str_replace("%%param%%", $this->config['edit']['where_get'], $this->args['where']);
			
			$this->view->assign(array(
				'content' => $this->value,
				'field_name' =>  $this->cfg['field_name'],
				'query_obj' => $this->db->select($this->args['table'], $this->args['fields'], $this->helper->eval_vars($this->args['where'], $this->row_value), true)
			));
			
			return $this->view->fetch('common/cast_sql_dropdown.tpl');
		}
		
		public function type_add()
		{
			$this->view->assign(array(
				'content' => '',
				'field_name' =>  $this->cfg['field_name'],
				'query_obj' => $this->db->select($this->args['table'], $this->args['fields'], $this->helper->eval_vars($this->args['where'], $this->row_value), true)
			));
			
			return $this->view->fetch('common/cast_sql_dropdown.tpl');		
		}
		
	}